#!/bin/bash
cd beijing
./transform.sh beijing.kml
cp beijing.json ..
cd ..

cd shanghai
./transform.sh shanghai.kml
cp shanghai.json ..
cd ..

cd guangzhou
./transform.sh guangzhou.kml
cp guangzhou.json ..
cd ..

if [ -f bsg.js ]
then
	rm bsg.js
fi

printf "var regions = {'请选择地区':{'detail':{'geoInfo':[102.945221,30.180224,6]}}" >> bsg.js
printf "," >> bsg.js
cat beijing.json >> bsg.js
printf "," >> bsg.js
cat shanghai.json >> bsg.js
printf "," >> bsg.js
cat guangzhou.json >> bsg.js
printf "}" >> bsg.js

sed -nr 'H; $ {x; s///g;p}' bsg.js | \
sed -nr 'H; $ {x; s/\n//g;p}' > /tmp/wmj_merge
cp /tmp/wmj_merge bsg.js

sed "s/var regions =\(.*\)$/[\1]/" bsg.js > bsg.json

